package panda.query.aggr;

import panda.query.scan.Scanner;
import panda.query.struct.Attribute;
import panda.query.struct.Constant;
import panda.query.struct.IntConstant;
import panda.query.struct.SemAttribute;

public class CountFn implements AggregateFn {
	Attribute nattr;
	Attribute attr;
	int count = 0;
	
	public CountFn(Attribute attr, Attribute nattr) {
		this.attr = attr;
		this.nattr = nattr;
	}
	
	public void first(Scanner s) {
		count = 1;
	}

	public void next(Scanner s) {
		count ++;
	}

	public Attribute getAttribute() {
		return nattr;
	}

	public Constant getValue() {
		return new IntConstant(count);
	}
	
}
